import { Component } from '@angular/core';
import { HttpService } from '../../config/http.service';
import { DownLoaderService } from '../../config/downloader.service';
import { Config } from '../../config/config.interface';

@Component({
  selector: 'app-testpages',
  templateUrl: './testpages.component.html',
  styleUrls: ['./testpages.component.less']
})
export class TestpagesComponent {
  title = 'myAngular';
  config: Config;
  headers;
  contents;
  constructor(private http: HttpService, private downloaderService: DownLoaderService) {

  }
  showConfig() {
    this.http.getConfig()
      .subscribe(resp => {
        const keys = resp.headers.keys();
        this.headers = keys.map(key =>
          `${key}: ${resp.headers.get(key)}`);
        this.config = {
          heroesUrl: resp.body['heroesUrl'],
          textfile: resp.body['textfile']
        }
      });
  }
  download() {
    this.downloaderService.getTextFile('assets/textfile.txt')
      .subscribe(results => this.contents = results);
  }
  login() {
    let params = {
      userPasswd: "e10adc3949ba59abbe56e057f20f883e",
      userPhone: "18304081154"
    }
    this.http.post('fire/fireUserLogin', params).subscribe(res => {
      if (+res.statusCode.code == 1004) {
        console.log(res);
      }
    });
  }
  getList() {
    let params = {
      action: "get",
      fireOrganizationalStructureEntity: { uuid: "45eb1baa-3aea-11e8-ab40-1418776c00b7" },
      firefightName: "",
      pageIndex: 1,
      pageSize: 10,
    }
    this.http.post('command/fireFighterInfoListAction', params).subscribe(res => {
      if (+res.statusCode.code == 1004) {
        console.log(res);
      }
    });
  }
 
}
